package conexao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import util.enviaEmail;

public class Conexao {

	public Connection getConexao() throws SQLException {
		
		Connection conn = null;
		String url = "";
		String user = "";
		String password = "";

		try {
			Class.forName("org.postgresql.Driver");
			
//			url = "jdbc:postgresql://pgsql.listarondonia.com.br:5432/list19br";
//			user = "list19br";
//			password = "17list39";
			
//			url = "jdbc:postgresql://localhost:5432/megasoft";
//			user = "postgres";
//			password = "fel0110";
			
			url = "jdbc:postgresql://postgres-rrcontrol.jelastic.websolute.net.br/list19br";
			user = "webadmin";
			password = "megalist#";
			
			conn = DriverManager.getConnection(url, user, password);
			conn.setAutoCommit(false);

		} catch (ClassNotFoundException e) {
			System.out.println("Drive de conexão não encontrado!");
			new enviaEmail().enviar(e);
			throw new RuntimeException(e);
		}
		
		return conn;
	
	}
	
}